package dto

import (

	"go-admin/app/admin/models"
	"go-admin/common/dto"
	common "go-admin/common/models"
)

type CategoriesGetPageReq struct {
	dto.Pagination     `search:"-"`
    Name string `form:"name"  search:"type:exact;column:name;table:categories" comment:"类别名称"`
    Description string `form:"description"  search:"type:contains;column:description;table:categories" comment:"描述"`
    Icon string `form:"icon"  search:"type:exact;column:icon;table:categories" comment:"图标"`
    Sort int64 `form:"sort"  search:"type:exact;column:sort;table:categories" comment:"排序"`
    Status string `form:"status"  search:"type:exact;column:status;table:categories" comment:"状态"`
    CategoriesOrder
}

type CategoriesOrder struct {
    Id string `form:"idOrder"  search:"type:order;column:id;table:categories"`
    Name string `form:"nameOrder"  search:"type:order;column:name;table:categories"`
    Description string `form:"descriptionOrder"  search:"type:order;column:description;table:categories"`
    Icon string `form:"iconOrder"  search:"type:order;column:icon;table:categories"`
    Sort string `form:"sortOrder"  search:"type:order;column:sort;table:categories"`
    Status string `form:"statusOrder"  search:"type:order;column:status;table:categories"`
    CreateBy string `form:"createByOrder"  search:"type:order;column:create_by;table:categories"`
    UpdateBy string `form:"updateByOrder"  search:"type:order;column:update_by;table:categories"`
    CreatedAt string `form:"createdAtOrder"  search:"type:order;column:created_at;table:categories"`
    UpdatedAt string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:categories"`
    DeletedAt string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:categories"`
    
}

func (m *CategoriesGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type CategoriesInsertReq struct {
    Id int `json:"-" comment:""` // 
    Name string `json:"name" comment:"类别名称"`
    Description string `json:"description" comment:"描述"`
    Icon string `json:"icon" comment:"图标"`
    Sort int64 `json:"sort" comment:"排序"`
    Status string `json:"status" comment:"状态"`
    common.ControlBy
}

func (s *CategoriesInsertReq) Generate(model *models.Categories)  {
    if s.Id == 0 {
        model.Model = common.Model{ Id: s.Id }
    }
    model.Name = s.Name
    model.Description = s.Description
    model.Icon = s.Icon
    model.Sort = s.Sort
    model.Status = s.Status
    model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
}

func (s *CategoriesInsertReq) GetId() interface{} {
	return s.Id
}

type CategoriesUpdateReq struct {
    Id int `uri:"id" comment:""` // 
    Name string `json:"name" comment:"类别名称"`
    Description string `json:"description" comment:"描述"`
    Icon string `json:"icon" comment:"图标"`
    Sort int64 `json:"sort" comment:"排序"`
    Status string `json:"status" comment:"状态"`
    common.ControlBy
}

func (s *CategoriesUpdateReq) Generate(model *models.Categories)  {
    if s.Id == 0 {
        model.Model = common.Model{ Id: s.Id }
    }
    model.Name = s.Name
    model.Description = s.Description
    model.Icon = s.Icon
    model.Sort = s.Sort
    model.Status = s.Status
    model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

func (s *CategoriesUpdateReq) GetId() interface{} {
	return s.Id
}

// CategoriesGetReq 功能获取请求参数
type CategoriesGetReq struct {
     Id int `uri:"id"`
}
func (s *CategoriesGetReq) GetId() interface{} {
	return s.Id
}

// CategoriesDeleteReq 功能删除请求参数
type CategoriesDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *CategoriesDeleteReq) GetId() interface{} {
	return s.Ids
}
